package com.sy.dao.impl;

import com.sy.dao.CollectDao;
import com.sy.entity.Collect;

import java.util.List;

public class CollectDaoImpl extends AbstractDaoImpl implements CollectDao {
    @Override
    public List<Integer> getCollectCarIdsByUserId(Integer userId) {
        return queryForColumnList("select carId from t_collect where userid=?", userId);
    }

    @Override
    public boolean deleteCollect(Integer userId, Integer carId) {
        return update("delete from t_collect where userid=? and carid=?", userId, carId);
    }

    @Override
    public boolean addCollect(Integer userId, Integer carId) {
        return update("insert into t_collect(userid,carid) values(?,?)", userId, carId);
    }

    @Override
    public Collect getCollectInfo(Integer userId, Integer carId) {
        return queryForObject("select * from t_collect where userid=? and carid=?", Collect.class, userId, carId);
    }
}
